Page({
  data: {
    userType: '',
    year: 2018,
    loginpage: false,
    titlename: ''
  },
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
    console.log(options);

    if (options.loginpage) {
      this.setData({
        loginpage: true
      });
    }
  },
  onReady: function () {
    // 页面渲染完成
  },
  onShow: function () {
    // 页面显示
    var userType = wx.getStorageSync('userType');

    if (userType == 1) {
      this.setData({
        userType: userType,
        titlename: '车公司'
      });
    } else if (userType == 2) {
      this.setData({
        userType: userType,
        titlename: '用车方'
      });
    } else if (userType == 3) {
      this.setData({
        userType: userType,
        titlename: '司机'
      });
    } else if (userType == 4) {
      this.setData({
        userType: userType,
        titlename: '导游'
      });
    } else if (userType == 5) {
      this.setData({
        userType: userType,
        titlename: '乘客'
      });
    }

    // this.setData({
    //   userType: userType,
    // });
    // console.log(this.data.userType)

    if (this.data.userType == '') {
      console.log('为空')
      this.setData({
        userType: 1,
        titlename: '车公司'
      });
    }
  },
  onHide: function () {
    // 页面隐藏
  },
  onUnload: function () {
    // 页面关闭
  },


  radioChange: function (e) {
    console.log('radio发生change事件，携带value值为：', e.detail.value);
    var roleType = e.detail.value;

    switch (roleType) {
      case 'car_company':
        this.setData({
          userType: 1,
          titlename: '车公司'
        });
        break;

      case 'travel_agency':
        this.setData({
          userType: 2,
          titlename: '用车方'
        });
        break;

      case 'driver':
        this.setData({
          userType: 3,
          titlename: '司机'
        });
        break;

      case 'guid':
        this.setData({
          userType: 4,
          titlename: '导游'
        });
        break;

      case 'passenger':
        this.setData({
          userType: 5,
          titlename: '乘客'
        });
        break;
    }
  },
})